1 00:00:30,000 --> 00:00:47,680 Hi, my name is Dave Morris and this is my first podcast for HPR. I want to talk to you 2 00:00:47,680 --> 00:00:56,840 on the subject of VIM plugins. I started using VI, Fair Time Ago when I was given the 3 00:00:56,840 --> 00:01:04,040 job of administering a bunch of multi-use, a unique systems. I found that VI was available 4 00:01:04,040 --> 00:01:09,480 on most of these systems. If it wasn't, then the alternative was a thing called 5 00:01:09,480 --> 00:01:17,320 edge, which was appalling. Anyway, whatever happened, EMAX was quite hard to combine. 6 00:01:17,320 --> 00:01:23,120 Certainly wasn't available on the machines out of the box. I'm not quite sure when I moved 7 00:01:23,120 --> 00:01:31,600 from VI to VIM and GIVIM. I might even be as long as 15 years ago. But since then, it's 8 00:01:31,600 --> 00:01:40,840 been my editor of choice and I've tended to use GIVIM and have it configured up as an IDE. 9 00:01:40,840 --> 00:01:47,760 It's not quite as smooth as a purpose-built IDE, but it's not bad as long as you know. 10 00:01:47,760 --> 00:01:55,600 It's a strangeness. Now for this talk, I'm assuming you know the basics of VIM. If you 11 00:01:55,600 --> 00:02:02,480 don't know how to install plugins, then I've pointed you to a very useful article in the 12 00:02:02,480 --> 00:02:09,000 show notes. The show notes all look so tell you where to get each of the plugins. And 13 00:02:09,000 --> 00:02:14,720 you'll notice that some of them have not been updated for a while. But my choice is 14 00:02:14,720 --> 00:02:21,680 the plugins tend to have quite high ratings. So hopefully they'll be useful to you. There are 15 00:02:21,680 --> 00:02:30,560 a few images in the notes, all of which are set up using GIVIM, for example. You need to have 16 00:02:30,560 --> 00:02:37,840 a good read of the help test text for each plugin if you decide to use them. So the 17 00:02:37,840 --> 00:02:43,200 first one I want to talk about is called Nerd Tree. I'm not quite sure where they came up with 18 00:02:43,200 --> 00:02:52,320 that name, but certainly a tree and it's used by this nerd. Anyway, it's a file browser which 19 00:02:52,320 --> 00:03:01,920 when you invoke it tends to sit on the left hand side of your window. I don't know if 20 00:03:01,920 --> 00:03:09,040 I'm assuming you know a bit about VIM Windows. Whatever it splits the main window and drops 21 00:03:09,040 --> 00:03:17,760 itself on the left hand side. You invoke it with a colon command. The colon commands open up the 22 00:03:19,120 --> 00:03:24,960 command line at the bottom of the window. You would type Nerd Tree and it's quite important to get 23 00:03:24,960 --> 00:03:32,960 the capitalization right. It's capital NERDT. Lowercase RW. Then you follow that with the directory 24 00:03:32,960 --> 00:03:42,160 name. I prefer to use Nerd Tree with GIVIM because it tends to be a generally more usable. You can 25 00:03:42,160 --> 00:03:48,960 use the mouse to click on things and scroll it and so on and so forth. Which I just generally 26 00:03:48,960 --> 00:03:56,160 find more usable. There are lots of key mappings within Nerd Tree, far too many to talk about here, 27 00:03:56,160 --> 00:04:02,960 but just give you a flavor. If you put your cursor on a directory in the Nerd Tree itself, 28 00:04:03,360 --> 00:04:10,800 then pressing T will open a new tab with that tree in it so you can be editing multiple files 29 00:04:10,800 --> 00:04:18,400 out of the same directory in different tabs. If you're not up to speed with VIM tabs, then I'll leave 30 00:04:18,400 --> 00:04:24,960 you to do a bit of investigation on that. It's a very, very powerful feature. I definitely recommend 31 00:04:24,960 --> 00:04:32,080 to use it. The other one I use quite a lot is putting the cursor on a directory pressing 32 00:04:32,080 --> 00:04:40,000 lowercase R, will of course the directory to be refreshed. Nerd Tree also offers bookmarks which you 33 00:04:40,000 --> 00:04:47,440 can create through various commands or key sequences which I won't go into. There are lots and 34 00:04:47,440 --> 00:04:54,080 lots of configuration options that you can put in the dot VIM or C file and I've given you some 35 00:04:54,080 --> 00:05:02,800 examples in the show notes where I make sure that Nerd Tree is only invoked when I'm in GVIM mode 36 00:05:02,800 --> 00:05:10,800 and not in standard VIM mode. I'll mention probably mention for every plugin actually the 37 00:05:10,800 --> 00:05:17,600 though the way that you get help, but mostly it's pretty much the same. You would type call on 38 00:05:17,600 --> 00:05:24,720 H or help if you wish H is the abbreviation followed by the name of the plugin and I didn't know 39 00:05:24,720 --> 00:05:29,120 myself actually but just discovered that pretty much all of these plugins don't care about the 40 00:05:29,120 --> 00:05:36,560 case of the the name that you type after the H and that's largely because the authors have made 41 00:05:36,560 --> 00:05:42,640 sure that the relevant tags are in the in the help files that will get you to where you want to be 42 00:05:42,640 --> 00:05:47,920 regardless of what case you you give. The other note though I thought you might be interested in is 43 00:05:48,720 --> 00:05:55,040 if you put your cursor in the Nerd Tree window and press the question mark then you get a quick help 44 00:05:55,040 --> 00:06:06,560 which is a quick abbreviation list of abbreviations for how to use the plugin. Okay so the next one 45 00:06:06,560 --> 00:06:15,920 it's called bash support. It this offers a lot of facilities that you'd expect to find in an 46 00:06:15,920 --> 00:06:25,200 IDE and as you can guess it's specifically designed for working with bash scripts. It adds a menu to 47 00:06:25,200 --> 00:06:31,840 GVIM called bash not surprisingly. Now you can look at the show notes to get an image of 48 00:06:31,840 --> 00:06:39,360 what it what it looks like with the menu open. I use it particularly to start each group with a 49 00:06:39,360 --> 00:06:45,520 standard header so that all of my scripts look pretty much the same contain the same sort of 50 00:06:45,520 --> 00:06:50,960 comments and and that type of thing. You can also do things like maintain a library of code snippets 51 00:06:50,960 --> 00:06:58,960 so you can you can paste into your code so thereby saving you from hunting about all over the place for 52 00:06:58,960 --> 00:07:06,080 ways to do things that you might have forgotten. It can do stuff like check the syntax of a script run 53 00:07:06,080 --> 00:07:13,040 it debug it and as usual there's a whole bunch of keyboard shortcuts. These in general 54 00:07:14,080 --> 00:07:21,600 begin with a backslash so a backslash CT lowercase inserts current date and time at the cursor 55 00:07:22,240 --> 00:07:27,440 which is great for putting time stamps in your in your comments or anything about sort 56 00:07:27,440 --> 00:07:35,280 of code and not too surprisingly help for this is invoked with call on h bash hyphen support 57 00:07:35,840 --> 00:07:41,760 or indeed bash without the hyphen support bash support just as one word so this particular 58 00:07:41,760 --> 00:07:47,040 writer has made sure that lots of tags in the file will get you to where you want to be in the 59 00:07:47,040 --> 00:07:53,760 help text. From the same stable as bash support is another plugin called Pearl support 60 00:07:53,760 --> 00:08:01,040 you're probably gathered that I'm a bash and Pearl scripter spend a fair bit of time writing these 61 00:08:01,040 --> 00:08:08,880 things. This one gives you equivalent facilities for editing Pearl scripts and it adds a Pearl 62 00:08:08,880 --> 00:08:18,000 menu to GVIM. I say that way because there are no menus in standard VIM. It's another bunch 63 00:08:18,000 --> 00:08:27,440 of GVIM of course and again I use it to form standard headers and I've got boiler plate which 64 00:08:27,440 --> 00:08:36,480 will create me a sort of standard empty script that I can then populate. Again you can manage code 65 00:08:36,480 --> 00:08:44,560 snippets with it and it will check syntax run on and debug a script. One of the functions I use 66 00:08:44,560 --> 00:08:52,880 quite a lot and it's called Pearl tidy. This is actually a standalone utility that you can use 67 00:08:52,880 --> 00:09:02,800 for the print when building a pulse script. It's abbreviation is backslase backslashri and what Pearl 68 00:09:02,800 --> 00:09:13,520 tidy does is to reformate your code and it does that according to its own built-in style but you 69 00:09:13,520 --> 00:09:20,960 can you can change that you can adjust it. So you can set up your own personal or house style. If 70 00:09:20,960 --> 00:09:26,720 you're part of a group doing collaborative programming it's it's amazingly important to have 71 00:09:26,720 --> 00:09:34,000 similar style otherwise you find it difficult to read somebody else's code. The way you can figure 72 00:09:34,000 --> 00:09:42,000 it is through a dot Pearl tidy RC file and there's loads of documentation about this. I personally 73 00:09:42,000 --> 00:09:50,320 prefer to use it through GVIM because it's a bit of a hassle to use standalone I find 74 00:09:50,320 --> 00:09:56,800 if to remember more. The other one I use the other part of the pulse pod that I use is Pearl critic. 75 00:09:56,800 --> 00:10:05,040 This is invoked with backslashriPC. This is a thing that does a compliance check with 76 00:10:05,040 --> 00:10:12,880 the best practices book written by Damian Conway is a big name in the Pearl community. 77 00:10:14,080 --> 00:10:20,880 There's an image in the show notes that shows a script being subjected to this. There's a certain 78 00:10:20,880 --> 00:10:28,240 sort of school-marmish feel to the way that it criticizes your code. It's times when you 79 00:10:28,880 --> 00:10:34,000 throw it out the window but on the whole it does some really useful things. You can turn 80 00:10:34,000 --> 00:10:39,920 up and down its level of criticism. Again it's more convenient to use through an editor than it 81 00:10:39,920 --> 00:10:48,400 is to use the standalone version. And finally you can invoke help for Pearl support by typing 82 00:10:48,400 --> 00:10:56,560 call on H Pearl support with or out without the hyphen. Next I want to mention plug-in called 83 00:10:56,560 --> 00:11:04,480 man-page view. Not too surprisingly this allows you to view man pages from within the editor. 84 00:11:05,360 --> 00:11:15,120 You invoke it by typing call on man with capital M, MAN space and then the topic. Or you can 85 00:11:15,120 --> 00:11:23,600 position your cursor on an editing window and press capital K and it will invoke the viewer. 86 00:11:23,600 --> 00:11:29,680 If it can if if the keyword has a man-page entry is relevant to man-page. So once you've got 87 00:11:29,680 --> 00:11:35,120 your man-page up you can search it and scroll it about cut and paste from it which is always 88 00:11:35,120 --> 00:11:39,360 very useful. There'll be good examples often in a man-page that you might want to try out. 89 00:11:39,360 --> 00:11:44,240 I certainly find this amazing in the useful saves hopping out of the editor and going to look at 90 00:11:44,240 --> 00:11:52,960 something on another window perhaps. It's help as usual is invoked with call on H man-page view. 91 00:11:54,480 --> 00:12:02,960 The next plug-in view is called surround. It allows you to add, delete or change so-called surroundings. 92 00:12:04,000 --> 00:12:10,800 By this I mean things like pairs of quotes, pairs of braces, parentheses and so forth. This one 93 00:12:10,800 --> 00:12:17,840 is driven entirely by key sequences. The examples that I've given you some examples in the show notes 94 00:12:17,840 --> 00:12:24,240 because it's it really needs something that you can look at to fully appreciate. But I'll just 95 00:12:24,240 --> 00:12:32,880 see whether I can speak about a couple of them. If your cursor is in an editing window inside a string 96 00:12:32,880 --> 00:12:43,440 enclosed in quotes then if you type ds both lowercase quote and then that's it yeah that's 97 00:12:43,440 --> 00:12:48,560 all your type. If you type that then it just deletes the quote ds quote deletes the quote. 98 00:12:48,560 --> 00:12:58,960 If you're inside a string in brackets square brackets then if you type cs square bracket 99 00:12:58,960 --> 00:13:08,720 closed that's closed square bracket closed parentheses then it will delete the square brackets 100 00:13:08,720 --> 00:13:14,800 and replace with parentheses. So you can see it's actually quite a powerful thing. 101 00:13:16,240 --> 00:13:20,960 Little hard to get your head round but personally I think well worth the trouble. 102 00:13:20,960 --> 00:13:30,240 Again as always you can get lots of help about how to use this with call on h surround. 103 00:13:31,760 --> 00:13:39,600 Next comes fugitive. This is an interface to the get version control system that you can use within 104 00:13:39,600 --> 00:13:47,920 the editor and I've put an example of what what the screen looks like if you type the command 105 00:13:47,920 --> 00:13:56,320 call on capital G status that's the equivalent of the command line get status that shows you the 106 00:13:56,320 --> 00:14:04,640 current state of repository. It gives access to pretty much all of the the get commands through 107 00:14:04,640 --> 00:14:12,640 one means or another either with direct commands or with commands to which you can add arguments. 108 00:14:12,640 --> 00:14:22,560 Again it's help is in book through call on h fugitive. Tag list is my next example. 109 00:14:23,760 --> 00:14:30,800 This is a plugin that lets you help. It gives you help with browsing source code. 110 00:14:31,680 --> 00:14:41,920 It creates a menu within gvm a menu is called tags and when you when you're editing a piece of source 111 00:14:41,920 --> 00:14:51,280 code then you'll find that the tags menu is populated with the functions classes and other major 112 00:14:52,480 --> 00:15:00,560 elements of your source code. You simply need to go to the menu and click on a tag to position 113 00:15:00,560 --> 00:15:09,200 the editor at that particular point. So if you're trying to find a the declaration of a 114 00:15:09,200 --> 00:15:15,680 subroutine whatever language you're dealing with then clicking on it will take you take you there. 115 00:15:16,560 --> 00:15:23,600 Under the hood it uses a package called exuberant c tags which is the most fantastic name 116 00:15:24,800 --> 00:15:33,040 and its job is to build a list of tags so it has syntactic knowledge of a whole bunch of 117 00:15:33,040 --> 00:15:43,200 languages which uses to build a tag file and this is then used by the tag list. There are other 118 00:15:43,200 --> 00:15:51,680 tag features within built into to them which I won't go into now but this I believe gives you 119 00:15:51,680 --> 00:16:01,280 a quite easy route to using this particular feature. There's an image in the show notes that 120 00:16:01,280 --> 00:16:07,760 gives you some idea of what you can do with it and now this there is not been telling you about 121 00:16:07,760 --> 00:16:13,200 how to get the help is that there are a few instances that don't conform to the normal 122 00:16:14,000 --> 00:16:21,280 normal way of doing it and in this this is one particular case. In this case you need to type 123 00:16:21,280 --> 00:16:32,480 call on hspace taglist.txt that's because the tag list is already a name within the standard 124 00:16:32,480 --> 00:16:42,560 them help file so that particular command invokes the things specific for this plugin. 125 00:16:42,560 --> 00:16:50,720 And my last plugin is called super tab. I think this is slightly controversial, 126 00:16:52,400 --> 00:16:58,720 partly because I'm not sure I like it. This provides word completion via the tab key. 127 00:16:59,600 --> 00:17:05,120 There's an example of it doing this in the show notes. So you type at least one character of the 128 00:17:05,120 --> 00:17:10,160 word that you're hoping to type you've forgotten how to spell it or something. You press tab 129 00:17:10,160 --> 00:17:17,600 and pop up menu comes up with the various options that this could be the various words that 130 00:17:17,600 --> 00:17:24,560 could match this. The thing that I'm not sure a like about this is that it hijacks the tab key 131 00:17:26,080 --> 00:17:32,320 and this means that if you want to enter a real tab for a new reason then you need to use control 132 00:17:32,320 --> 00:17:38,000 tab to do it which I'm not sure I want. I would like to be able to switch this on and off as I 133 00:17:38,000 --> 00:17:45,440 need it and I haven't yet found a way of doing it. There are other tab completion plugins available 134 00:17:45,440 --> 00:17:50,480 which I have not tested yet. I think I'm going to do that and see if there's something better 135 00:17:50,480 --> 00:17:59,040 than this. This seems to be the most popular one judging by the rating though. So that's my list of 136 00:17:59,040 --> 00:18:07,360 plugins. This is quite a quick review. There's a lot to be said about each one. Each could have a 137 00:18:07,360 --> 00:18:13,440 podcast to itself, I guess, if anybody would ever listen. The other thing to tell you is there's a 138 00:18:13,440 --> 00:18:21,520 whole world of plugins available on www.vim.org. Very very large and about you can browse through. 139 00:18:22,320 --> 00:18:24,080 So hope you found that useful. 140 00:18:29,440 --> 00:18:33,280 You have been listening to Hector Public Radio as Hector Public Radio does our 141 00:18:33,280 --> 00:18:38,240 we are a community podcast network that releases shows every week that you want to take the 142 00:18:38,240 --> 00:18:45,280 Friday. Today's show by GoR shows was contributed by a HPR listener like yourself. If you ever 143 00:18:45,280 --> 00:18:50,560 consider recording a podcast then visit our website to find out how easy it really is. 144 00:18:50,560 --> 00:18:55,760 Hector Public Radio was founded by the digital.power and the economic and computer cloud. 145 00:18:55,760 --> 00:19:02,080 HPR is funded by the binary revolution at bingreff.com. All bingreff projects across 146 00:19:02,080 --> 00:19:08,000 this sponsored by Lena Pages. From shared hosting to custom private clouds, go to 147 00:19:08,000 --> 00:19:14,720 LenaPages.com for all your hosting needs. On this otherwise stages, today's show is released 148 00:19:14,720 --> 00:19:34,720 on your creative comments at the future. Share and like. He does our life as well.